/* eslint-disable */
<template>
  <div>
<!--    <div>-->
<!--      图谱ID:{{this.KG.kgInfo.id}} 图谱名称:{{this.KG.kgInfo.name}}-->
<!--    </div>-->
    <el-table
      :data="tableData"
      row-key="id"
      height="300"
      border
      style="width: 100%">
      <el-table-column
        prop="item"
        label="条目"
        style="height:30px;width: 50%">
      </el-table-column>
      <el-table-column
        prop="content"
        label="数量"
        style="height:30px;width: 25%">
      </el-table-column>
      <el-table-column
        prop="remark"
        label="备注"
        style="height:30px;width: 25%">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

let Item = function(id,item,content,remark,children) {
  this.id = id;
  this.item = item;
  this.content = content;
  this.remark = remark;
  this.children = children;
}

export default {
  name: "statisticsKgComponent",
  data(){
    return{
      tableData: [],
      KG: this.$parent.$parent.$refs.graphComponent.KG
    }
  },
  created() {
    console.log("table init")
    this.initTableData();
  },
  methods: {
    initTableData(){
      let index = -1;
      // this.tableData[++index] = new Item(index,"图谱ID",this.KG.kgInfo.id);
      // this.tableData[++index] = new Item(index,"图谱名称",this.KG.kgInfo.name);
      this.tableData[++index] = new Item(index,"节点",this.KG.kgInfo.nodes.length,"图谱包含的节点数");
      this.tableData[++index] = new Item(index,"展示节点",this.KG.kgInfo.visibleNodes.length,"未隐藏的节点数");
      this.tableData[++index] = new Item(index,"连接",this.KG.kgInfo.links.length,"图谱包含的连接的数");
      this.tableData[++index] = new Item(index,"展示连接",this.KG.kgInfo.visibleLinks.length,"未被隐藏的连接数");
      this.tableData[++index] = new Item(index,"节点类型",this.KG.kgInfo.typeList.length,"节点类型种类数",this.getTypeNodesCountArr(index));

    },
    getTypeNodesCountArr(indexFrom){
      let _this = this;
      let index = indexFrom;
      let arr = [];
      let typeList = this.KG.kgInfo.typeList;
      typeList.forEach(function(type){
        let count = _this.KG.getNodesByTypeName(type.name).length;
        arr[++index] = new Item(index,type.name,count,"类型包含节点数");
      });
      return arr;
    }
  }
};
</script>

<style scoped>

</style>